<?

Smutty_Main::loadClass(
	'Smutty_Database_Result'
);

/**
 *  singleton for the database
 *
 */

class Smutty_Database {

	var $cnn = null;

	function getInstance() {
		static $instance;
		// need to use === as false means we've tried to
		// connect but something has gone wrong!
		if ( $instance === null ) {
			$cfg = Smutty_Config::getInstance();
			switch ( strtolower($cfg->get('db.type')) ) {
				case 'mysql':
					Smutty_Main::loadClass( 'Smutty_Database_MySQL' );
					$instance = new Smutty_Database_MySQL();
					break;
				default:
					$instance = false; // need to set this to avoid infinite loop of
									// code in the error handler trying to get
									// a db handle.
					new Smutty_Exception( 'unknown database type db.type in app.cfg', 'SmuttyConfig' );
			}
			$instance->connect();
		}
		return $instance;
	}

	function connect() {
		new Smutty_Exception( ERR_NOT_IMPLEMENTED, 'ClassSmutty_Database' );
	}

	function query( $sql ) {
		new Smutty_Exception( ERR_NOT_IMPLEMENTED, 'ClassSmutty_Database' );
	}

	function update( $sql ) {
		new Smutty_Exception( ERR_NOT_IMPLEMENTED, 'ClassSmutty_Database' );
	}

	function quote( $string ) {
		new Smutty_Exception( ERR_NOT_IMPLEMENTED, 'ClassSmutty_Database' );
	}

	function getInsertId() {
		new Smutty_Exception( ERR_NOT_IMPLEMENTED, 'ClassSmutty_Database' );
	}

	function getError() {
		new Smutty_Exception( ERR_NOT_IMPLEMENTED, 'ClassSmutty_Database' );
	}

	function getCurrentDate() {
		new Smutty_Exception( ERR_NOT_IMPLEMENTED, 'ClassSmutty_Database' );
	}

	function getFieldsSql( $table ) {
		new Smutty_Exception( ERR_NOT_IMPLEMENTED, 'ClassSmutty_Database' );
	}

	function getDateFormat() {
		new Smutty_Exception( ERR_NOT_IMPLEMENTED, 'ClassSmutty_Database' );
	}

}

?>